package org.springsource.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import org.codehaus.jackson.annotate.JsonBackReference;

@Embeddable
public class AccountCategoryId implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3982876562431523055L;
	private Account account;
	
	private Category category;
	
	
	
	@ManyToOne
	@JsonBackReference("categories")
	public Account getAccount() {
		return account;
	}
	public void setAccount(Account account) {
		this.account = account;
	}
	@ManyToOne
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}
	@Override
	public boolean equals(Object o){
		if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
 
        AccountCategoryId that = (AccountCategoryId) o;
 
        if (account != null ? !account.equals(that.account) : that.account != null) return false;
        if (category != null ? !category.equals(that.category) : that.category != null)
            return false;
        return true;
		
	}
	@Override
	public int hashCode() {
        int result;
        result = (account != null ? account.hashCode() : 0);
        result = 31 * result + (category != null ? category.hashCode() : 0);
        return result;
    }
}
